<template>
	<div class="pay-box">
		<div class="pay-suc-box">
			<p class="pay-success"><span>{{payMethod}}</span>成功!{{time}}</p>
			<span @click="tipt">查看订单</span>
		</div>
	</div>
</template>

<script>
	export default{
		name:"pay",
		data(){
			return{
				time:5,
				auto:null,
				payMethod:null
			}
		},
		methods:{
			tipt(){
				this.$router.replace("/myOrder")
			}
		},
		mounted() {
			this.auto = setInterval(()=>{
				this.time --
				if(this.time <=0){
					this.$router.replace("/myOrder")
					clearInterval(this.auto)
				}
			},1000)
		},
		created() {
			let payMet = this.$route.query.pay;
			switch(parseInt(payMet)){
				case 0:
				this.payMethod = "微信支付"
				break;
				case 1:
				this.payMethod = "支付宝支付"
				break;
			}
		},
		beforeDestroy() {
			clearInterval(this.auto)
		}
	}
</script>

<style scoped="scoped">
	@import url("../css/publice.css");
	.pay-box{
		width: 100%;
		display: flex;
		justify-content: center;
		
	}
	.pay-suc-box{
		position: fixed;
		top: 3rem;
		width: 5rem;
		height: 1.5rem;
		background-color: gainsboro;
		display: flex;
		border-radius: 0.1rem;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
	.pay-suc-box span{
		color: deepskyblue;
		padding: 0.2rem;
	}
	.pay-success{
		font-size: 0.3rem;
	}
	.pay-success span{
		color: skyblue;
	}
</style>
